close #17
							parent
							
								
									d569e67642
								
							
						
					
					
						commit
						5316686d2d
					
				| 
						 | 
				
			
			@ -57,9 +57,9 @@ module.exports = function(grunt) {
 | 
			
		|||
      },
 | 
			
		||||
    },
 | 
			
		||||
    cssmin: {
 | 
			
		||||
       options: {
 | 
			
		||||
      options: {
 | 
			
		||||
        keepSpecialComments: 0
 | 
			
		||||
    },
 | 
			
		||||
      },
 | 
			
		||||
      target: {
 | 
			
		||||
        files: [{
 | 
			
		||||
          expand: true,
 | 
			
		||||
| 
						 | 
				
			
			@ -84,8 +84,7 @@ module.exports = function(grunt) {
 | 
			
		|||
            'node_modules/codemirror/mode/javascript/javascript.js',
 | 
			
		||||
            'node_modules/codemirror/mode/markdown/markdown.js',
 | 
			
		||||
            'node_modules/codemirror/mode/sass/sass.js',
 | 
			
		||||
            'node_modules/codemirror/mode/htmlmixed/htmlmixed.js',
 | 
			
		||||
            'node_modules/js-cookie/src/js.cookie.js'
 | 
			
		||||
            'node_modules/codemirror/mode/htmlmixed/htmlmixed.js'
 | 
			
		||||
          ]
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
| 
						 | 
				
			
			@ -98,4 +97,4 @@ module.exports = function(grunt) {
 | 
			
		|||
  });
 | 
			
		||||
 | 
			
		||||
  grunt.registerTask('default', ['copy', 'sass', 'concat', 'cssmin', 'uglify']);
 | 
			
		||||
};
 | 
			
		||||
};
 | 
			
		||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| 
						 | 
				
			
			@ -152,64 +152,6 @@ $(document).on('ready pjax:success', function() {
 | 
			
		|||
      }
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    // If it has a textarea
 | 
			
		||||
    if (textarea[0]) {
 | 
			
		||||
      options = {
 | 
			
		||||
        mode: textarea.data("mode"),
 | 
			
		||||
        theme: 'mdn-like',
 | 
			
		||||
        lineWrapping: true,
 | 
			
		||||
        lineNumbers: true,
 | 
			
		||||
        scrollbarStyle: null
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (textarea.data("mode") == "markdown") {
 | 
			
		||||
        options.lineNumbers = false
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      editor = CodeMirror.fromTextArea(textarea[0], options);
 | 
			
		||||
      codemirror = $('.CodeMirror');
 | 
			
		||||
 | 
			
		||||
      // Toggles between preview and editing mode
 | 
			
		||||
      $("#preview").click(function(event) {
 | 
			
		||||
        event.preventDefault();
 | 
			
		||||
 | 
			
		||||
        // If it currently in the preview mode, hide the preview
 | 
			
		||||
        // and show the editor
 | 
			
		||||
        if ($(this).data("previewing") == "true") {
 | 
			
		||||
          preview.hide();
 | 
			
		||||
          codemirror.fadeIn();
 | 
			
		||||
          $(this).data("previewing", "false");
 | 
			
		||||
          notification({
 | 
			
		||||
            text: "Think, relax and do the better you can!",
 | 
			
		||||
            type: 'information',
 | 
			
		||||
            timeout: 2000
 | 
			
		||||
          });
 | 
			
		||||
        } else {
 | 
			
		||||
          // Copy the editor content to texteare
 | 
			
		||||
          editor.save()
 | 
			
		||||
 | 
			
		||||
          // If it's in editing mode, convert the markdown to html
 | 
			
		||||
          // and show it
 | 
			
		||||
          var converter = new showdown.Converter(),
 | 
			
		||||
            text = textarea.val(),
 | 
			
		||||
            html = converter.makeHtml(text);
 | 
			
		||||
 | 
			
		||||
          // Hide the editor and show the preview
 | 
			
		||||
          codemirror.hide();
 | 
			
		||||
          preview.html(html).fadeIn();
 | 
			
		||||
 | 
			
		||||
          $(this).data("previewing", "true");
 | 
			
		||||
          notification({
 | 
			
		||||
            text: "This is how your post looks like.",
 | 
			
		||||
            type: 'information',
 | 
			
		||||
            timeout: 2000
 | 
			
		||||
          });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return false;
 | 
			
		||||
      });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Submites any form in the page in JSON format
 | 
			
		||||
    $('form').submit(function(event) {
 | 
			
		||||
      event.preventDefault();
 | 
			
		||||
| 
						 | 
				
			
			@ -255,7 +197,8 @@ $(document).on('ready pjax:success', function() {
 | 
			
		|||
    $("body").on('click', '.add', function(event) {
 | 
			
		||||
      event.preventDefault();
 | 
			
		||||
 | 
			
		||||
      if ($("#new").length) {
 | 
			
		||||
      if ($("#new-admin-item-123").length) {
 | 
			
		||||
        console.log("oi")
 | 
			
		||||
        return false;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -266,8 +209,8 @@ $(document).on('ready pjax:success', function() {
 | 
			
		|||
 | 
			
		||||
      if (title.is('h1')) {
 | 
			
		||||
        fieldset = $('.frontmatter .container');
 | 
			
		||||
        fieldset.prepend('<div id="ghost"></div>');
 | 
			
		||||
        title = $('#ghost');
 | 
			
		||||
        fieldset.prepend('<div id="ghost-admin-item-123"></div>');
 | 
			
		||||
        title = $('#ghost-admin-item-123');
 | 
			
		||||
        type = "object";
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -276,13 +219,13 @@ $(document).on('ready pjax:success', function() {
 | 
			
		|||
      }
 | 
			
		||||
 | 
			
		||||
      if (type == "object") {
 | 
			
		||||
        title.after('<input id="new" placeholder="Write the field name and press enter..."></input>');
 | 
			
		||||
        element = $("#new");
 | 
			
		||||
        title.after('<input id="new-admin-item-123" placeholder="Write the field name and press enter..."></input>');
 | 
			
		||||
        element = $("#new-admin-item-123");
 | 
			
		||||
 | 
			
		||||
        if (!Cookies.get('placeholdertip')) {
 | 
			
		||||
          Cookies.set('placeholdertip', 'true', {
 | 
			
		||||
            expires: 365
 | 
			
		||||
          });
 | 
			
		||||
        if (!document.cookie.replace(/(?:(?:^|.*;\s*)placeholdertip\s*\=\s*([^;]*).*$)|^.*$/, "$1")) {
 | 
			
		||||
          var date = new Date();
 | 
			
		||||
          date.setDate(date.getDate() + 365);
 | 
			
		||||
          document.cookie = 'placeholdertip=true; expires=' + date.toUTCString + '; path=/';
 | 
			
		||||
 | 
			
		||||
          notification({
 | 
			
		||||
            text: 'Write the field name and then press enter. If you want to create an array or an object, end the name with ":array" or ":object".',
 | 
			
		||||
| 
						 | 
				
			
			@ -352,5 +295,63 @@ $(document).on('ready pjax:success', function() {
 | 
			
		|||
 | 
			
		||||
      return false;
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    // If it has a textarea
 | 
			
		||||
    if (textarea[0]) {
 | 
			
		||||
      options = {
 | 
			
		||||
        mode: textarea.data("mode"),
 | 
			
		||||
        theme: 'mdn-like',
 | 
			
		||||
        lineWrapping: true,
 | 
			
		||||
        lineNumbers: true,
 | 
			
		||||
        scrollbarStyle: null
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (textarea.data("mode") == "markdown") {
 | 
			
		||||
        options.lineNumbers = false
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      editor = CodeMirror.fromTextArea(textarea[0], options);
 | 
			
		||||
      codemirror = $('.CodeMirror');
 | 
			
		||||
 | 
			
		||||
      // Toggles between preview and editing mode
 | 
			
		||||
      $("#preview").click(function(event) {
 | 
			
		||||
        event.preventDefault();
 | 
			
		||||
 | 
			
		||||
        // If it currently in the preview mode, hide the preview
 | 
			
		||||
        // and show the editor
 | 
			
		||||
        if ($(this).data("previewing") == "true") {
 | 
			
		||||
          preview.hide();
 | 
			
		||||
          codemirror.fadeIn();
 | 
			
		||||
          $(this).data("previewing", "false");
 | 
			
		||||
          notification({
 | 
			
		||||
            text: "Think, relax and do the better you can!",
 | 
			
		||||
            type: 'information',
 | 
			
		||||
            timeout: 2000
 | 
			
		||||
          });
 | 
			
		||||
        } else {
 | 
			
		||||
          // Copy the editor content to texteare
 | 
			
		||||
          editor.save()
 | 
			
		||||
 | 
			
		||||
          // If it's in editing mode, convert the markdown to html
 | 
			
		||||
          // and show it
 | 
			
		||||
          var converter = new showdown.Converter(),
 | 
			
		||||
            text = textarea.val(),
 | 
			
		||||
            html = converter.makeHtml(text);
 | 
			
		||||
 | 
			
		||||
          // Hide the editor and show the preview
 | 
			
		||||
          codemirror.hide();
 | 
			
		||||
          preview.html(html).fadeIn();
 | 
			
		||||
 | 
			
		||||
          $(this).data("previewing", "true");
 | 
			
		||||
          notification({
 | 
			
		||||
            text: "This is how your post looks like.",
 | 
			
		||||
            type: 'information',
 | 
			
		||||
            timeout: 2000
 | 
			
		||||
          });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return false;
 | 
			
		||||
      });
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			@ -69,10 +69,10 @@ notification = function(options) {
 | 
			
		|||
  options = $.extend({}, defaults, options);
 | 
			
		||||
  noty(options);
 | 
			
		||||
 | 
			
		||||
  if (!Cookies.get('stickynoties') && !options.timeout) {
 | 
			
		||||
    Cookies.set('stickynoties', 'true', {
 | 
			
		||||
      expires: 365
 | 
			
		||||
    });
 | 
			
		||||
  if (!document.cookie.replace(/(?:(?:^|.*;\s*)stickynoties\s*\=\s*([^;]*).*$)|^.*$/, "$1") && !options.timeout) {
 | 
			
		||||
    var date = new Date();
 | 
			
		||||
    date.setDate(date.getDate() + 365);
 | 
			
		||||
    document.cookie = 'stickynoties=true; expires=' + date.toUTCString + '; path=/';
 | 
			
		||||
 | 
			
		||||
    notification({
 | 
			
		||||
      text: "Some notifications are sticky. If it doesn't go away, click to dismiss it.",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,7 +22,6 @@
 | 
			
		|||
    "font-awesome": "^4.4.0",
 | 
			
		||||
    "jquery": "^2.1.4",
 | 
			
		||||
    "jquery-serializejson": "^2.5.0",
 | 
			
		||||
    "js-cookie": "^2.0.3",
 | 
			
		||||
    "normalize.css": "^3.0.3",
 | 
			
		||||
    "noty": "^2.3.6",
 | 
			
		||||
    "perfect-scrollbar": "^0.6.4",
 | 
			
		||||
| 
						 | 
				
			
			@ -38,4 +37,4 @@
 | 
			
		|||
    "grunt-contrib-watch": "^0.6.1",
 | 
			
		||||
    "napa": "^1.2.0"
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue