Bootstrap completed
This commit is contained in:
217
js/FileSaver.js
Normal file
217
js/FileSaver.js
Normal file
@@ -0,0 +1,217 @@
|
||||
|
||||
/* FileSaver.js
|
||||
* A saveAs() FileSaver implementation.
|
||||
* 2013-01-23
|
||||
*
|
||||
* By Eli Grey, http://eligrey.com
|
||||
* License: X11/MIT
|
||||
* See LICENSE.md
|
||||
*/
|
||||
|
||||
/*global self */
|
||||
/*jslint bitwise: true, regexp: true, confusion: true, es5: true, vars: true, white: true,
|
||||
plusplus: true */
|
||||
|
||||
/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
|
||||
|
||||
var saveAs = saveAs
|
||||
|| (navigator.msSaveBlob && navigator.msSaveBlob.bind(navigator))
|
||||
|| (function(view) {
|
||||
"use strict";
|
||||
var
|
||||
doc = view.document
|
||||
// only get URL when necessary in case BlobBuilder.js hasn't overridden it yet
|
||||
, get_URL = function() {
|
||||
return view.URL || view.webkitURL || view;
|
||||
}
|
||||
, URL = view.URL || view.webkitURL || view
|
||||
, save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a")
|
||||
, can_use_save_link = "download" in save_link
|
||||
, click = function(node) {
|
||||
var event = doc.createEvent("MouseEvents");
|
||||
event.initMouseEvent(
|
||||
"click", true, false, view, 0, 0, 0, 0, 0
|
||||
, false, false, false, false, 0, null
|
||||
);
|
||||
node.dispatchEvent(event);
|
||||
}
|
||||
, webkit_req_fs = view.webkitRequestFileSystem
|
||||
, req_fs = view.requestFileSystem || webkit_req_fs || view.mozRequestFileSystem
|
||||
, throw_outside = function (ex) {
|
||||
(view.setImmediate || view.setTimeout)(function() {
|
||||
throw ex;
|
||||
}, 0);
|
||||
}
|
||||
, force_saveable_type = "application/octet-stream"
|
||||
, fs_min_size = 0
|
||||
, deletion_queue = []
|
||||
, process_deletion_queue = function() {
|
||||
var i = deletion_queue.length;
|
||||
while (i--) {
|
||||
var file = deletion_queue[i];
|
||||
if (typeof file === "string") { // file is an object URL
|
||||
URL.revokeObjectURL(file);
|
||||
} else { // file is a File
|
||||
file.remove();
|
||||
}
|
||||
}
|
||||
deletion_queue.length = 0; // clear queue
|
||||
}
|
||||
, dispatch = function(filesaver, event_types, event) {
|
||||
event_types = [].concat(event_types);
|
||||
var i = event_types.length;
|
||||
while (i--) {
|
||||
var listener = filesaver["on" + event_types[i]];
|
||||
if (typeof listener === "function") {
|
||||
try {
|
||||
listener.call(filesaver, event || filesaver);
|
||||
} catch (ex) {
|
||||
throw_outside(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
, FileSaver = function(blob, name) {
|
||||
// First try a.download, then web filesystem, then object URLs
|
||||
var
|
||||
filesaver = this
|
||||
, type = blob.type
|
||||
, blob_changed = false
|
||||
, object_url
|
||||
, target_view
|
||||
, get_object_url = function() {
|
||||
var object_url = get_URL().createObjectURL(blob);
|
||||
deletion_queue.push(object_url);
|
||||
return object_url;
|
||||
}
|
||||
, dispatch_all = function() {
|
||||
dispatch(filesaver, "writestart progress write writeend".split(" "));
|
||||
}
|
||||
// on any filesys errors revert to saving with object URLs
|
||||
, fs_error = function() {
|
||||
// don't create more object URLs than needed
|
||||
if (blob_changed || !object_url) {
|
||||
object_url = get_object_url(blob);
|
||||
}
|
||||
if (target_view) {
|
||||
target_view.location.href = object_url;
|
||||
}
|
||||
filesaver.readyState = filesaver.DONE;
|
||||
dispatch_all();
|
||||
}
|
||||
, abortable = function(func) {
|
||||
return function() {
|
||||
if (filesaver.readyState !== filesaver.DONE) {
|
||||
return func.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
}
|
||||
, create_if_not_found = {create: true, exclusive: false}
|
||||
, slice
|
||||
;
|
||||
filesaver.readyState = filesaver.INIT;
|
||||
if (!name) {
|
||||
name = "download";
|
||||
}
|
||||
if (can_use_save_link) {
|
||||
object_url = get_object_url(blob);
|
||||
save_link.href = object_url;
|
||||
save_link.download = name;
|
||||
click(save_link);
|
||||
filesaver.readyState = filesaver.DONE;
|
||||
dispatch_all();
|
||||
return;
|
||||
}
|
||||
// Object and web filesystem URLs have a problem saving in Google Chrome when
|
||||
// viewed in a tab, so I force save with application/octet-stream
|
||||
// http://code.google.com/p/chromium/issues/detail?id=91158
|
||||
if (view.chrome && type && type !== force_saveable_type) {
|
||||
slice = blob.slice || blob.webkitSlice;
|
||||
blob = slice.call(blob, 0, blob.size, force_saveable_type);
|
||||
blob_changed = true;
|
||||
}
|
||||
// Since I can't be sure that the guessed media type will trigger a download
|
||||
// in WebKit, I append .download to the filename.
|
||||
// https://bugs.webkit.org/show_bug.cgi?id=65440
|
||||
if (webkit_req_fs && name !== "download") {
|
||||
name += ".download";
|
||||
}
|
||||
if (type === force_saveable_type || webkit_req_fs) {
|
||||
target_view = view;
|
||||
} else {
|
||||
target_view = view.open();
|
||||
}
|
||||
if (!req_fs) {
|
||||
fs_error();
|
||||
return;
|
||||
}
|
||||
fs_min_size += blob.size;
|
||||
req_fs(view.TEMPORARY, fs_min_size, abortable(function(fs) {
|
||||
fs.root.getDirectory("saved", create_if_not_found, abortable(function(dir) {
|
||||
var save = function() {
|
||||
dir.getFile(name, create_if_not_found, abortable(function(file) {
|
||||
file.createWriter(abortable(function(writer) {
|
||||
writer.onwriteend = function(event) {
|
||||
target_view.location.href = file.toURL();
|
||||
deletion_queue.push(file);
|
||||
filesaver.readyState = filesaver.DONE;
|
||||
dispatch(filesaver, "writeend", event);
|
||||
};
|
||||
writer.onerror = function() {
|
||||
var error = writer.error;
|
||||
if (error.code !== error.ABORT_ERR) {
|
||||
fs_error();
|
||||
}
|
||||
};
|
||||
"writestart progress write abort".split(" ").forEach(function(event) {
|
||||
writer["on" + event] = filesaver["on" + event];
|
||||
});
|
||||
writer.write(blob);
|
||||
filesaver.abort = function() {
|
||||
writer.abort();
|
||||
filesaver.readyState = filesaver.DONE;
|
||||
};
|
||||
filesaver.readyState = filesaver.WRITING;
|
||||
}), fs_error);
|
||||
}), fs_error);
|
||||
};
|
||||
dir.getFile(name, {create: false}, abortable(function(file) {
|
||||
// delete file if it already exists
|
||||
file.remove();
|
||||
save();
|
||||
}), abortable(function(ex) {
|
||||
if (ex.code === ex.NOT_FOUND_ERR) {
|
||||
save();
|
||||
} else {
|
||||
fs_error();
|
||||
}
|
||||
}));
|
||||
}), fs_error);
|
||||
}), fs_error);
|
||||
}
|
||||
, FS_proto = FileSaver.prototype
|
||||
, saveAs = function(blob, name) {
|
||||
return new FileSaver(blob, name);
|
||||
}
|
||||
;
|
||||
FS_proto.abort = function() {
|
||||
var filesaver = this;
|
||||
filesaver.readyState = filesaver.DONE;
|
||||
dispatch(filesaver, "abort");
|
||||
};
|
||||
FS_proto.readyState = FS_proto.INIT = 0;
|
||||
FS_proto.WRITING = 1;
|
||||
FS_proto.DONE = 2;
|
||||
|
||||
FS_proto.error =
|
||||
FS_proto.onwritestart =
|
||||
FS_proto.onprogress =
|
||||
FS_proto.onwrite =
|
||||
FS_proto.onabort =
|
||||
FS_proto.onerror =
|
||||
FS_proto.onwriteend =
|
||||
null;
|
||||
|
||||
view.addEventListener("unload", process_deletion_queue, false);
|
||||
return saveAs;
|
||||
}(self));
|
||||
179
js/blob.js
Normal file
179
js/blob.js
Normal file
@@ -0,0 +1,179 @@
|
||||
|
||||
/* Blob.js
|
||||
* A Blob implementation.
|
||||
* 2013-06-20
|
||||
*
|
||||
* By Eli Grey, http://eligrey.com
|
||||
* By Devin Samarin, https://github.com/eboyjr
|
||||
* License: X11/MIT
|
||||
* See LICENSE.md
|
||||
*/
|
||||
|
||||
/*global self, unescape */
|
||||
/*jslint bitwise: true, regexp: true, confusion: true, es5: true, vars: true, white: true,
|
||||
plusplus: true */
|
||||
|
||||
/*! @source http://purl.eligrey.com/github/Blob.js/blob/master/Blob.js */
|
||||
|
||||
if (typeof Blob !== "function" || typeof URL === "undefined")
|
||||
if (typeof Blob === "function" && typeof webkitURL !== "undefined") var URL = webkitURL;
|
||||
else var Blob = (function (view) {
|
||||
"use strict";
|
||||
|
||||
var BlobBuilder = view.BlobBuilder || view.WebKitBlobBuilder || view.MozBlobBuilder || view.MSBlobBuilder || (function(view) {
|
||||
var
|
||||
get_class = function(object) {
|
||||
return Object.prototype.toString.call(object).match(/^\[object\s(.*)\]$/)[1];
|
||||
}
|
||||
, FakeBlobBuilder = function BlobBuilder() {
|
||||
this.data = [];
|
||||
}
|
||||
, FakeBlob = function Blob(data, type, encoding) {
|
||||
this.data = data;
|
||||
this.size = data.length;
|
||||
this.type = type;
|
||||
this.encoding = encoding;
|
||||
}
|
||||
, FBB_proto = FakeBlobBuilder.prototype
|
||||
, FB_proto = FakeBlob.prototype
|
||||
, FileReaderSync = view.FileReaderSync
|
||||
, FileException = function(type) {
|
||||
this.code = this[this.name = type];
|
||||
}
|
||||
, file_ex_codes = (
|
||||
"NOT_FOUND_ERR SECURITY_ERR ABORT_ERR NOT_READABLE_ERR ENCODING_ERR "
|
||||
+ "NO_MODIFICATION_ALLOWED_ERR INVALID_STATE_ERR SYNTAX_ERR"
|
||||
).split(" ")
|
||||
, file_ex_code = file_ex_codes.length
|
||||
, real_URL = view.URL || view.webkitURL || view
|
||||
, real_create_object_URL = real_URL.createObjectURL
|
||||
, real_revoke_object_URL = real_URL.revokeObjectURL
|
||||
, URL = real_URL
|
||||
, btoa = view.btoa
|
||||
, atob = view.atob
|
||||
, can_apply_typed_arrays = false
|
||||
, can_apply_typed_arrays_test = function(pass) {
|
||||
can_apply_typed_arrays = !pass;
|
||||
}
|
||||
|
||||
, ArrayBuffer = view.ArrayBuffer
|
||||
, Uint8Array = view.Uint8Array
|
||||
;
|
||||
FakeBlob.fake = FB_proto.fake = true;
|
||||
while (file_ex_code--) {
|
||||
FileException.prototype[file_ex_codes[file_ex_code]] = file_ex_code + 1;
|
||||
}
|
||||
try {
|
||||
if (Uint8Array) {
|
||||
can_apply_typed_arrays_test.apply(0, new Uint8Array(1));
|
||||
}
|
||||
} catch (ex) {}
|
||||
if (!real_URL.createObjectURL) {
|
||||
URL = view.URL = {};
|
||||
}
|
||||
URL.createObjectURL = function(blob) {
|
||||
var
|
||||
type = blob.type
|
||||
, data_URI_header
|
||||
;
|
||||
if (type === null) {
|
||||
type = "application/octet-stream";
|
||||
}
|
||||
if (blob instanceof FakeBlob) {
|
||||
data_URI_header = "data:" + type;
|
||||
if (blob.encoding === "base64") {
|
||||
return data_URI_header + ";base64," + blob.data;
|
||||
} else if (blob.encoding === "URI") {
|
||||
return data_URI_header + "," + decodeURIComponent(blob.data);
|
||||
} if (btoa) {
|
||||
return data_URI_header + ";base64," + btoa(blob.data);
|
||||
} else {
|
||||
return data_URI_header + "," + encodeURIComponent(blob.data);
|
||||
}
|
||||
} else if (real_create_object_URL) {
|
||||
return real_create_object_URL.call(real_URL, blob);
|
||||
}
|
||||
};
|
||||
URL.revokeObjectURL = function(object_URL) {
|
||||
if (object_URL.substring(0, 5) !== "data:" && real_revoke_object_URL) {
|
||||
real_revoke_object_URL.call(real_URL, object_URL);
|
||||
}
|
||||
};
|
||||
FBB_proto.append = function(data/*, endings*/) {
|
||||
var bb = this.data;
|
||||
// decode data to a binary string
|
||||
if (Uint8Array && (data instanceof ArrayBuffer || data instanceof Uint8Array)) {
|
||||
if (can_apply_typed_arrays) {
|
||||
bb.push(String.fromCharCode.apply(String, new Uint8Array(data)));
|
||||
} else {
|
||||
var
|
||||
str = ""
|
||||
, buf = new Uint8Array(data)
|
||||
, i = 0
|
||||
, buf_len = buf.length
|
||||
;
|
||||
for (; i < buf_len; i++) {
|
||||
str += String.fromCharCode(buf[i]);
|
||||
}
|
||||
}
|
||||
} else if (get_class(data) === "Blob" || get_class(data) === "File") {
|
||||
if (FileReaderSync) {
|
||||
var fr = new FileReaderSync;
|
||||
bb.push(fr.readAsBinaryString(data));
|
||||
} else {
|
||||
// async FileReader won't work as BlobBuilder is sync
|
||||
throw new FileException("NOT_READABLE_ERR");
|
||||
}
|
||||
} else if (data instanceof FakeBlob) {
|
||||
if (data.encoding === "base64" && atob) {
|
||||
bb.push(atob(data.data));
|
||||
} else if (data.encoding === "URI") {
|
||||
bb.push(decodeURIComponent(data.data));
|
||||
} else if (data.encoding === "raw") {
|
||||
bb.push(data.data);
|
||||
}
|
||||
} else {
|
||||
if (typeof data !== "string") {
|
||||
data += ""; // convert unsupported types to strings
|
||||
}
|
||||
// decode UTF-16 to binary string
|
||||
bb.push(unescape(encodeURIComponent(data)));
|
||||
}
|
||||
};
|
||||
FBB_proto.getBlob = function(type) {
|
||||
if (!arguments.length) {
|
||||
type = null;
|
||||
}
|
||||
return new FakeBlob(this.data.join(""), type, "raw");
|
||||
};
|
||||
FBB_proto.toString = function() {
|
||||
return "[object BlobBuilder]";
|
||||
};
|
||||
FB_proto.slice = function(start, end, type) {
|
||||
var args = arguments.length;
|
||||
if (args < 3) {
|
||||
type = null;
|
||||
}
|
||||
return new FakeBlob(
|
||||
this.data.slice(start, args > 1 ? end : this.data.length)
|
||||
, type
|
||||
, this.encoding
|
||||
);
|
||||
};
|
||||
FB_proto.toString = function() {
|
||||
return "[object Blob]";
|
||||
};
|
||||
return FakeBlobBuilder;
|
||||
}(view));
|
||||
|
||||
return function Blob(blobParts, options) {
|
||||
var type = options ? (options.type || "") : "";
|
||||
var builder = new BlobBuilder();
|
||||
if (blobParts) {
|
||||
for (var i = 0, len = blobParts.length; i < len; i++) {
|
||||
builder.append(blobParts[i]);
|
||||
}
|
||||
}
|
||||
return builder.getBlob(type);
|
||||
};
|
||||
}(self));
|
||||
9
js/bootstrap.min.js
vendored
Normal file
9
js/bootstrap.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
108
js/canvas-toBlob.js
Normal file
108
js/canvas-toBlob.js
Normal file
@@ -0,0 +1,108 @@
|
||||
|
||||
/* canvas-toBlob.js
|
||||
* A canvas.toBlob() implementation.
|
||||
* 2011-07-13
|
||||
*
|
||||
* By Eli Grey, http://eligrey.com and Devin Samarin, https://github.com/eboyjr
|
||||
* License: X11/MIT
|
||||
* See LICENSE.md
|
||||
*/
|
||||
|
||||
/*global self */
|
||||
/*jslint bitwise: true, regexp: true, confusion: true, es5: true, vars: true, white: true,
|
||||
plusplus: true */
|
||||
|
||||
/*! @source http://purl.eligrey.com/github/canvas-toBlob.js/blob/master/canvas-toBlob.js */
|
||||
|
||||
(function(view) {
|
||||
"use strict";
|
||||
var
|
||||
Uint8Array = view.Uint8Array
|
||||
, HTMLCanvasElement = view.HTMLCanvasElement
|
||||
, is_base64_regex = /\s*;\s*base64\s*(?:;|$)/i
|
||||
, base64_ranks
|
||||
, decode_base64 = function(base64) {
|
||||
var
|
||||
len = base64.length
|
||||
, buffer = new Uint8Array(len / 4 * 3 | 0)
|
||||
, i = 0
|
||||
, outptr = 0
|
||||
, last = [0, 0]
|
||||
, state = 0
|
||||
, save = 0
|
||||
, rank
|
||||
, code
|
||||
, undef
|
||||
;
|
||||
while (len--) {
|
||||
code = base64.charCodeAt(i++);
|
||||
rank = base64_ranks[code-43];
|
||||
if (rank !== 255 && rank !== undef) {
|
||||
last[1] = last[0];
|
||||
last[0] = code;
|
||||
save = (save << 6) | rank;
|
||||
state++;
|
||||
if (state === 4) {
|
||||
buffer[outptr++] = save >>> 16;
|
||||
if (last[1] !== 61 /* padding character */) {
|
||||
buffer[outptr++] = save >>> 8;
|
||||
}
|
||||
if (last[0] !== 61 /* padding character */) {
|
||||
buffer[outptr++] = save;
|
||||
}
|
||||
state = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 2/3 chance there's going to be some null bytes at the end, but that
|
||||
// doesn't really matter with most image formats.
|
||||
// If it somehow matters for you, truncate the buffer up outptr.
|
||||
return buffer.buffer;
|
||||
}
|
||||
;
|
||||
if (Uint8Array) {
|
||||
base64_ranks = new Uint8Array([
|
||||
62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1
|
||||
, -1, -1, 0, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
|
||||
, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25
|
||||
, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35
|
||||
, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51
|
||||
]);
|
||||
}
|
||||
if (HTMLCanvasElement && !HTMLCanvasElement.prototype.toBlob) {
|
||||
HTMLCanvasElement.prototype.toBlob = function(callback, type /*, ...args*/) {
|
||||
if (!type) {
|
||||
type = "image/png";
|
||||
} if (this.mozGetAsFile) {
|
||||
callback(this.mozGetAsFile("canvas", type));
|
||||
return;
|
||||
}
|
||||
var
|
||||
args = Array.prototype.slice.call(arguments, 1)
|
||||
, dataURI = this.toDataURL.apply(this, args)
|
||||
, header_end = dataURI.indexOf(",")
|
||||
, data = dataURI.substring(header_end + 1)
|
||||
, is_base64 = is_base64_regex.test(dataURI.substring(0, header_end))
|
||||
, blob
|
||||
;
|
||||
if (Blob.fake) {
|
||||
// no reason to decode a data: URI that's just going to become a data URI again
|
||||
blob = new Blob
|
||||
if (is_base64) {
|
||||
blob.encoding = "base64";
|
||||
} else {
|
||||
blob.encoding = "URI";
|
||||
}
|
||||
blob.data = data;
|
||||
blob.size = data.length;
|
||||
} else if (Uint8Array) {
|
||||
if (is_base64) {
|
||||
blob = new Blob([decode_base64(data)], {type: type});
|
||||
} else {
|
||||
blob = new Blob([decodeURIComponent(data)], {type: type});
|
||||
}
|
||||
}
|
||||
callback(blob);
|
||||
};
|
||||
}
|
||||
}(self));
|
||||
8
js/html5shiv.js
vendored
Normal file
8
js/html5shiv.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
HTML5 Shiv v3.6.2 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
|
||||
*/
|
||||
(function(l,f){function m(){var a=e.elements;return"string"==typeof a?a.split(" "):a}function i(a){var b=n[a[o]];b||(b={},h++,a[o]=h,n[h]=b);return b}function p(a,b,c){b||(b=f);if(g)return b.createElement(a);c||(c=i(b));b=c.cache[a]?c.cache[a].cloneNode():r.test(a)?(c.cache[a]=c.createElem(a)).cloneNode():c.createElem(a);return b.canHaveChildren&&!s.test(a)?c.frag.appendChild(b):b}function t(a,b){if(!b.cache)b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag();
|
||||
a.createElement=function(c){return!e.shivMethods?b.createElem(c):p(c,a,b)};a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+m().join().replace(/\w+/g,function(a){b.createElem(a);b.frag.createElement(a);return'c("'+a+'")'})+");return n}")(e,b.frag)}function q(a){a||(a=f);var b=i(a);if(e.shivCSS&&!j&&!b.hasCSS){var c,d=a;c=d.createElement("p");d=d.getElementsByTagName("head")[0]||d.documentElement;c.innerHTML="x<style>article,aside,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}</style>";
|
||||
c=d.insertBefore(c.lastChild,d.firstChild);b.hasCSS=!!c}g||t(a,b);return a}var k=l.html5||{},s=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,r=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,j,o="_html5shiv",h=0,n={},g;(function(){try{var a=f.createElement("a");a.innerHTML="<xyz></xyz>";j="hidden"in a;var b;if(!(b=1==a.childNodes.length)){f.createElement("a");var c=f.createDocumentFragment();b="undefined"==typeof c.cloneNode||
|
||||
"undefined"==typeof c.createDocumentFragment||"undefined"==typeof c.createElement}g=b}catch(d){g=j=!0}})();var e={elements:k.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup main mark meter nav output progress section summary time video",version:"3.6.2",shivCSS:!1!==k.shivCSS,supportsUnknownElements:g,shivMethods:!1!==k.shivMethods,type:"default",shivDocument:q,createElement:p,createDocumentFragment:function(a,b){a||(a=f);if(g)return a.createDocumentFragment();
|
||||
for(var b=b||i(a),c=b.frag.cloneNode(),d=0,e=m(),h=e.length;d<h;d++)c.createElement(e[d]);return c}};l.html5=e;q(f)})(this,document);
|
||||
6
js/jquery-2.0.0.min.js
vendored
Normal file
6
js/jquery-2.0.0.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
12
js/jquery-ui.js
vendored
Normal file
12
js/jquery-ui.js
vendored
Normal file
File diff suppressed because one or more lines are too long
576
js/jquery.htmlClean.js
Normal file
576
js/jquery.htmlClean.js
Normal file
@@ -0,0 +1,576 @@
|
||||
/*
|
||||
HTML Clean for jQuery
|
||||
Anthony Johnston
|
||||
http://www.antix.co.uk
|
||||
|
||||
version 1.3.1
|
||||
|
||||
$Revision$
|
||||
|
||||
requires jQuery http://jquery.com
|
||||
|
||||
Use and distibution http://www.opensource.org/licenses/bsd-license.php
|
||||
|
||||
2010-04-02 allowedTags/removeTags added (white/black list) thanks to David Wartian (Dwartian)
|
||||
2010-06-30 replaceStyles added for replacement of bold, italic, super and sub styles on a tag
|
||||
2012-04-30 allowedAttributes added, an array of attributed allowed on the elements
|
||||
2013-02-25 now will push non-inline elements up the stack if nested in an inline element
|
||||
2013-02-25 comment element support added, removed by default, see AllowComments in options
|
||||
*/
|
||||
(function ($) {
|
||||
$.fn.htmlClean = function (options) {
|
||||
// iterate and html clean each matched element
|
||||
return this.each(function () {
|
||||
var $this = $(this);
|
||||
if (this.value) {
|
||||
this.value = $.htmlClean(this.value, options);
|
||||
} else {
|
||||
this.innerHTML = $.htmlClean(this.innerHTML, options);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// clean the passed html
|
||||
$.htmlClean = function (html, options) {
|
||||
options = $.extend({}, $.htmlClean.defaults, options);
|
||||
|
||||
var tagsRE = /(<(\/)?(\w+:)?([\w]+)([^>]*)>)|<!--(.*?--)>/gi;
|
||||
var attrsRE = /([\w\-]+)=(".*?"|'.*?'|[^\s>]*)/gi;
|
||||
|
||||
var tagMatch;
|
||||
var root = new Element();
|
||||
var stack = [root];
|
||||
var container = root;
|
||||
var protect = false;
|
||||
|
||||
if (options.bodyOnly) {
|
||||
// check for body tag
|
||||
if (tagMatch = /<body[^>]*>((\n|.)*)<\/body>/i.exec(html)) {
|
||||
html = tagMatch[1];
|
||||
}
|
||||
}
|
||||
html = html.concat("<xxx>"); // ensure last element/text is found
|
||||
var lastIndex;
|
||||
|
||||
while (tagMatch = tagsRE.exec(html)) {
|
||||
var tag = tagMatch[6]
|
||||
? new Tag("--", null, tagMatch[6], options)
|
||||
: new Tag(tagMatch[4], tagMatch[2], tagMatch[5], options);
|
||||
|
||||
// add the text
|
||||
var text = html.substring(lastIndex, tagMatch.index);
|
||||
if (text.length > 0) {
|
||||
var child = container.children[container.children.length - 1];
|
||||
if (container.children.length > 0
|
||||
&& isText(child = container.children[container.children.length - 1])) {
|
||||
// merge text
|
||||
container.children[container.children.length - 1] = child.concat(text);
|
||||
} else {
|
||||
container.children.push(text);
|
||||
}
|
||||
}
|
||||
lastIndex = tagsRE.lastIndex;
|
||||
|
||||
if (tag.isClosing) {
|
||||
// find matching container
|
||||
if (popToTagName(stack, [tag.name])) {
|
||||
stack.pop();
|
||||
container = stack[stack.length - 1];
|
||||
}
|
||||
} else {
|
||||
// create a new element
|
||||
var element = new Element(tag);
|
||||
|
||||
// add attributes
|
||||
var attrMatch;
|
||||
while (attrMatch = attrsRE.exec(tag.rawAttributes)) {
|
||||
|
||||
// check style attribute and do replacements
|
||||
if (attrMatch[1].toLowerCase() == "style"
|
||||
&& options.replaceStyles) {
|
||||
|
||||
var renderParent = !tag.isInline;
|
||||
for (var i = 0; i < options.replaceStyles.length; i++) {
|
||||
if (options.replaceStyles[i][0].test(attrMatch[2])) {
|
||||
|
||||
if (!renderParent) {
|
||||
tag.render = false;
|
||||
renderParent = true;
|
||||
}
|
||||
container.children.push(element); // assumes not replaced
|
||||
stack.push(element);
|
||||
container = element; // assumes replacement is a container
|
||||
// create new tag and element
|
||||
tag = new Tag(options.replaceStyles[i][1], "", "", options);
|
||||
element = new Element(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tag.allowedAttributes != null
|
||||
&& (tag.allowedAttributes.length == 0
|
||||
|| $.inArray(attrMatch[1], tag.allowedAttributes) > -1)) {
|
||||
element.attributes.push(new Attribute(attrMatch[1], attrMatch[2]));
|
||||
}
|
||||
}
|
||||
// add required empty ones
|
||||
$.each(tag.requiredAttributes, function () {
|
||||
var name = this.toString();
|
||||
if (!element.hasAttribute(name)) element.attributes.push(new Attribute(name, ""));
|
||||
});
|
||||
|
||||
// check for replacements
|
||||
for (var repIndex = 0; repIndex < options.replace.length; repIndex++) {
|
||||
for (var tagIndex = 0; tagIndex < options.replace[repIndex][0].length; tagIndex++) {
|
||||
var byName = typeof (options.replace[repIndex][0][tagIndex]) == "string";
|
||||
if ((byName && options.replace[repIndex][0][tagIndex] == tag.name)
|
||||
|| (!byName && options.replace[repIndex][0][tagIndex].test(tagMatch))) {
|
||||
|
||||
// set the name to the replacement
|
||||
tag.rename(options.replace[repIndex][1]);
|
||||
|
||||
repIndex = options.replace.length; // break out of both loops
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check container rules
|
||||
var add = true;
|
||||
if (!container.isRoot) {
|
||||
if (container.tag.isInline && !tag.isInline) {
|
||||
if (add = popToContainer(stack)) {
|
||||
container = stack[stack.length - 1];
|
||||
}
|
||||
} else if (container.tag.disallowNest && tag.disallowNest
|
||||
&& !tag.requiredParent) {
|
||||
add = false;
|
||||
} else if (tag.requiredParent) {
|
||||
if (add = popToTagName(stack, tag.requiredParent)) {
|
||||
container = stack[stack.length - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (add) {
|
||||
container.children.push(element);
|
||||
|
||||
if (tag.toProtect) {
|
||||
// skip to closing tag
|
||||
while (tagMatch2 = tagsRE.exec(html)) {
|
||||
var tag2 = new Tag(tagMatch2[3], tagMatch2[1], tagMatch2[4], options);
|
||||
if (tag2.isClosing && tag2.name == tag.name) {
|
||||
element.children.push(RegExp.leftContext.substring(lastIndex));
|
||||
lastIndex = tagsRE.lastIndex;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// set as current container element
|
||||
if (!tag.isSelfClosing && !tag.isNonClosing) {
|
||||
stack.push(element);
|
||||
container = element;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// render doc
|
||||
return $.htmlClean.trim(render(root, options).join(""));
|
||||
};
|
||||
|
||||
// defaults
|
||||
$.htmlClean.defaults = {
|
||||
// only clean the body tagbody
|
||||
bodyOnly: true,
|
||||
// only allow tags in this array, (white list), contents still rendered
|
||||
allowedTags: [],
|
||||
// remove tags in this array, (black list), contents still rendered
|
||||
removeTags: ["basefont", "center", "dir", "font", "frame", "frameset", "iframe", "isindex", "menu", "noframes", "s", "strike", "u"],
|
||||
// array of [attributeName], [optional array of allowed on elements] e.g. [["id"], ["style", ["p", "dl"]]] // allow all elements to have id and allow style on 'p' and 'dl'
|
||||
allowedAttributes: [],
|
||||
// array of attribute names to remove on all elements in addition to those not in tagAttributes e.g ["width", "height"]
|
||||
removeAttrs: [],
|
||||
// array of [className], [optional array of allowed on elements] e.g. [["aClass"], ["anotherClass", ["p", "dl"]]]
|
||||
allowedClasses: [],
|
||||
// format the result
|
||||
format: false,
|
||||
// format indent to start on
|
||||
formatIndent: 0,
|
||||
// tags to replace, and what to replace with, tag name or regex to match the tag and attributes
|
||||
replace: [
|
||||
[["b", "big"], "strong"],
|
||||
[["i"], "em"]
|
||||
],
|
||||
// styles to replace with tags, multiple style matches supported, inline tags are replaced by the first match blocks are retained
|
||||
replaceStyles: [
|
||||
[/font-weight:\s*bold/i, "strong"],
|
||||
[/font-style:\s*italic/i, "em"],
|
||||
[/vertical-align:\s*super/i, "sup"],
|
||||
[/vertical-align:\s*sub/i, "sub"]
|
||||
],
|
||||
allowComments: false
|
||||
};
|
||||
|
||||
function applyFormat(element, options, output, indent) {
|
||||
if (!element.tag.isInline && output.length > 0) {
|
||||
output.push("\n");
|
||||
for (i = 0; i < indent; i++) output.push("\t");
|
||||
}
|
||||
}
|
||||
|
||||
function render(element, options) {
|
||||
var output = [], empty = element.attributes.length == 0, indent;
|
||||
|
||||
if (element.tag.isComment) {
|
||||
if (options.allowComments) {
|
||||
output.push("<!--");
|
||||
output.push(element.tag.rawAttributes);
|
||||
output.push(">");
|
||||
|
||||
if (options.format) applyFormat(element, options, output, indent - 1);
|
||||
}
|
||||
} else {
|
||||
|
||||
var openingTag = this.name.concat(element.tag.rawAttributes == undefined ? "" : element.tag.rawAttributes);
|
||||
|
||||
// don't render if not in allowedTags or in removeTags
|
||||
var renderTag
|
||||
= element.tag.render
|
||||
&& (options.allowedTags.length == 0 || $.inArray(element.tag.name, options.allowedTags) > -1)
|
||||
&& (options.removeTags.length == 0 || $.inArray(element.tag.name, options.removeTags) == -1);
|
||||
|
||||
if (!element.isRoot && renderTag) {
|
||||
|
||||
// render opening tag
|
||||
output.push("<");
|
||||
output.push(element.tag.name);
|
||||
$.each(element.attributes, function () {
|
||||
if ($.inArray(this.name, options.removeAttrs) == -1) {
|
||||
var m = RegExp(/^(['"]?)(.*?)['"]?$/).exec(this.value);
|
||||
var value = m[2];
|
||||
var valueQuote = m[1] || "'";
|
||||
|
||||
// check for classes allowed
|
||||
if (this.name == "class" && options.allowedClasses.length > 0) {
|
||||
value =
|
||||
$.grep(value.split(" "), function (c) {
|
||||
return $.grep(options.allowedClasses, function (a) {
|
||||
return a == c
|
||||
|| (a[0] == c && (a.length == 1 || $.inArray(element.tag.name, a[1]) > -1));
|
||||
}).length > 0;
|
||||
})
|
||||
.join(" ");
|
||||
}
|
||||
|
||||
if (value != null && (value.length > 0 || $.inArray(this.name, element.tag.requiredAttributes) > -1)) {
|
||||
output.push(" ");
|
||||
output.push(this.name);
|
||||
output.push("=");
|
||||
output.push(valueQuote);
|
||||
output.push(value);
|
||||
output.push(valueQuote);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (element.tag.isSelfClosing) {
|
||||
// self closing
|
||||
if (renderTag) output.push(" />");
|
||||
empty = false;
|
||||
} else if (element.tag.isNonClosing) {
|
||||
empty = false;
|
||||
} else {
|
||||
if (!element.isRoot && renderTag) {
|
||||
// close
|
||||
output.push(">");
|
||||
}
|
||||
|
||||
var indent = options.formatIndent++;
|
||||
|
||||
// render children
|
||||
if (element.tag.toProtect) {
|
||||
var outputChildren = $.htmlClean.trim(element.children.join("")).replace(/<br>/ig, "\n");
|
||||
output.push(outputChildren);
|
||||
empty = outputChildren.length == 0;
|
||||
} else {
|
||||
var outputChildren = [];
|
||||
for (var i = 0; i < element.children.length; i++) {
|
||||
var child = element.children[i];
|
||||
var text = $.htmlClean.trim(textClean(isText(child) ? child : child.childrenToString()));
|
||||
if (isInline(child)) {
|
||||
if (i > 0 && text.length > 0
|
||||
&& (startsWithWhitespace(child) || endsWithWhitespace(element.children[i - 1]))) {
|
||||
outputChildren.push(" ");
|
||||
}
|
||||
}
|
||||
if (isText(child)) {
|
||||
if (text.length > 0) {
|
||||
outputChildren.push(text);
|
||||
}
|
||||
} else {
|
||||
// don't allow a break to be the last child
|
||||
if (i != element.children.length - 1 || child.tag.name != "br") {
|
||||
if (options.format) applyFormat(child, options, outputChildren, indent);
|
||||
outputChildren = outputChildren.concat(render(child, options));
|
||||
}
|
||||
}
|
||||
}
|
||||
options.formatIndent--;
|
||||
|
||||
if (outputChildren.length > 0) {
|
||||
if (options.format && outputChildren[0] != "\n") applyFormat(element, options, output, indent);
|
||||
output = output.concat(outputChildren);
|
||||
empty = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!element.isRoot && renderTag) {
|
||||
// render the closing tag
|
||||
if (options.format) applyFormat(element, options, output, indent - 1);
|
||||
output.push("</");
|
||||
output.push(element.tag.name);
|
||||
output.push(">");
|
||||
}
|
||||
}
|
||||
|
||||
// check for empty tags
|
||||
if (!element.tag.allowEmpty && empty) { return []; }
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
// find a matching tag, and pop to it, if not do nothing
|
||||
function popToTagName(stack, tagNameArray) {
|
||||
return pop(
|
||||
stack,
|
||||
function (element) {
|
||||
return $.inArray(element.tag.nameOriginal, tagNameArray) > -1
|
||||
});
|
||||
}
|
||||
|
||||
function popToContainer(stack) {
|
||||
return pop(
|
||||
stack,
|
||||
function (element) {
|
||||
return element.isRoot || !element.tag.isInline;
|
||||
});
|
||||
}
|
||||
|
||||
function pop(stack, test, index) {
|
||||
index = index || 1;
|
||||
var element = stack[stack.length - index];
|
||||
if (test(element)) {
|
||||
return true;
|
||||
} else if (stack.length - index > 0
|
||||
&& pop(stack, test, index + 1)) {
|
||||
stack.pop();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Element Object
|
||||
function Element(tag) {
|
||||
if (tag) {
|
||||
this.tag = tag;
|
||||
this.isRoot = false;
|
||||
} else {
|
||||
this.tag = new Tag("root");
|
||||
this.isRoot = true;
|
||||
}
|
||||
this.attributes = [];
|
||||
this.children = [];
|
||||
|
||||
this.hasAttribute = function (name) {
|
||||
for (var i = 0; i < this.attributes.length; i++) {
|
||||
if (this.attributes[i].name == name) return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
this.childrenToString = function () {
|
||||
return this.children.join("");
|
||||
};
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
// Attribute Object
|
||||
function Attribute(name, value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
// Tag object
|
||||
function Tag(name, close, rawAttributes, options) {
|
||||
this.name = name.toLowerCase();
|
||||
this.nameOriginal = this.name;
|
||||
this.render = true;
|
||||
|
||||
this.init = function () {
|
||||
if (this.name == "--") {
|
||||
this.isComment = true;
|
||||
this.isSelfClosing = true;
|
||||
} else {
|
||||
this.isComment = false;
|
||||
this.isSelfClosing = $.inArray(this.name, tagSelfClosing) > -1;
|
||||
this.isNonClosing = $.inArray(this.name, tagNonClosing) > -1;
|
||||
this.isClosing = (close != undefined && close.length > 0);
|
||||
|
||||
this.isInline = $.inArray(this.name, tagInline) > -1;
|
||||
this.disallowNest = $.inArray(this.name, tagDisallowNest) > -1;
|
||||
this.requiredParent = tagRequiredParent[$.inArray(this.name, tagRequiredParent) + 1];
|
||||
this.allowEmpty = $.inArray(this.name, tagAllowEmpty) > -1;
|
||||
|
||||
this.toProtect = $.inArray(this.name, tagProtect) > -1;
|
||||
}
|
||||
this.rawAttributes = rawAttributes;
|
||||
this.requiredAttributes = tagAttributesRequired[$.inArray(this.name, tagAttributesRequired) + 1];
|
||||
|
||||
if (options) {
|
||||
if (!options.tagAttributesCache) options.tagAttributesCache = [];
|
||||
if ($.inArray(this.name, options.tagAttributesCache) == -1) {
|
||||
var cacheItem = tagAttributes[$.inArray(this.name, tagAttributes) + 1].slice(0);
|
||||
|
||||
// add extra ones from options
|
||||
for (var i = 0; i < options.allowedAttributes.length; i++) {
|
||||
var attrName = options.allowedAttributes[i][0];
|
||||
if ((
|
||||
options.allowedAttributes[i].length == 1
|
||||
|| $.inArray(this.name, options.allowedAttributes[i][1]) > -1
|
||||
) && $.inArray(attrName, cacheItem) == -1) {
|
||||
cacheItem.push(attrName);
|
||||
}
|
||||
}
|
||||
|
||||
options.tagAttributesCache.push(this.name);
|
||||
options.tagAttributesCache.push(cacheItem);
|
||||
}
|
||||
|
||||
this.allowedAttributes = options.tagAttributesCache[$.inArray(this.name, options.tagAttributesCache) + 1];
|
||||
}
|
||||
}
|
||||
|
||||
this.init();
|
||||
|
||||
this.rename = function (newName) {
|
||||
this.name = newName;
|
||||
this.init();
|
||||
};
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
function startsWithWhitespace(item) {
|
||||
while (isElement(item) && item.children.length > 0) { item = item.children[0] }
|
||||
if (!isText(item)) return false;
|
||||
var text = textClean(item);
|
||||
return text.length > 0 && $.htmlClean.isWhitespace(text.charAt(0));
|
||||
}
|
||||
function endsWithWhitespace(item) {
|
||||
while (isElement(item) && item.children.length > 0) { item = item.children[item.children.length - 1] }
|
||||
if (!isText(item)) return false;
|
||||
var text = textClean(item);
|
||||
return text.length > 0 && $.htmlClean.isWhitespace(text.charAt(text.length - 1));
|
||||
}
|
||||
function isText(item) { return item.constructor == String; }
|
||||
function isInline(item) { return isText(item) || item.tag.isInline; }
|
||||
function isElement(item) { return item.constructor == Element; }
|
||||
function textClean(text) {
|
||||
return text
|
||||
.replace(/ |\n/g, " ")
|
||||
.replace(/\s\s+/g, " ");
|
||||
}
|
||||
|
||||
// trim off white space, doesn't use regex
|
||||
$.htmlClean.trim = function (text) {
|
||||
return $.htmlClean.trimStart($.htmlClean.trimEnd(text));
|
||||
};
|
||||
$.htmlClean.trimStart = function (text) {
|
||||
return text.substring($.htmlClean.trimStartIndex(text));
|
||||
};
|
||||
$.htmlClean.trimStartIndex = function (text) {
|
||||
for (var start = 0; start < text.length - 1 && $.htmlClean.isWhitespace(text.charAt(start)); start++);
|
||||
return start;
|
||||
};
|
||||
$.htmlClean.trimEnd = function (text) {
|
||||
return text.substring(0, $.htmlClean.trimEndIndex(text));
|
||||
};
|
||||
$.htmlClean.trimEndIndex = function (text) {
|
||||
for (var end = text.length - 1; end >= 0 && $.htmlClean.isWhitespace(text.charAt(end)); end--);
|
||||
return end + 1;
|
||||
};
|
||||
// checks a char is white space or not
|
||||
$.htmlClean.isWhitespace = function (c) { return $.inArray(c, whitespace) != -1; };
|
||||
|
||||
// tags which are inline
|
||||
var tagInline = [
|
||||
"a", "abbr", "acronym", "address", "b", "big", "br", "button",
|
||||
"caption", "cite", "code", "del", "em", "font",
|
||||
"hr", "i", "input", "img", "ins", "label", "legend", "map", "q",
|
||||
"s", "samp", "select", "option", "param", "small", "span", "strike", "strong", "sub", "sup",
|
||||
"tt", "u", "var"];
|
||||
var tagDisallowNest = ["h1", "h2", "h3", "h4", "h5", "h6", "p", "th", "td", "object"];
|
||||
var tagAllowEmpty = ["th", "td"];
|
||||
var tagRequiredParent = [
|
||||
null,
|
||||
"li", ["ul", "ol"],
|
||||
"dt", ["dl"],
|
||||
"dd", ["dl"],
|
||||
"td", ["tr"],
|
||||
"th", ["tr"],
|
||||
"tr", ["table", "thead", "tbody", "tfoot"],
|
||||
"thead", ["table"],
|
||||
"tbody", ["table"],
|
||||
"tfoot", ["table"],
|
||||
"param", ["object"]
|
||||
];
|
||||
var tagProtect = ["script", "style", "pre", "code"];
|
||||
// tags which self close e.g. <br />
|
||||
var tagSelfClosing = ["area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
|
||||
// tags which do not close
|
||||
var tagNonClosing = ["!doctype", "?xml"];
|
||||
// attributes allowed on tags
|
||||
var tagAttributes = [
|
||||
["class"], // default, for all tags not mentioned
|
||||
"?xml", [],
|
||||
"!doctype", [],
|
||||
"a", ["accesskey", "class", "href", "name", "title", "rel", "rev", "type", "tabindex"],
|
||||
"abbr", ["class", "title"],
|
||||
"acronym", ["class", "title"],
|
||||
"blockquote", ["cite", "class"],
|
||||
"button", ["class", "disabled", "name", "type", "value"],
|
||||
"del", ["cite", "class", "datetime"],
|
||||
"form", ["accept", "action", "class", "enctype", "method", "name"],
|
||||
"input", ["accept", "accesskey", "alt", "checked", "class", "disabled", "ismap", "maxlength", "name", "size", "readonly", "src", "tabindex", "type", "usemap", "value"],
|
||||
"img", ["alt", "class", "height", "src", "width"],
|
||||
"ins", ["cite", "class", "datetime"],
|
||||
"label", ["accesskey", "class", "for"],
|
||||
"legend", ["accesskey", "class"],
|
||||
"link", ["href", "rel", "type"],
|
||||
"meta", ["content", "http-equiv", "name", "scheme", "charset"],
|
||||
"map", ["name"],
|
||||
"optgroup", ["class", "disabled", "label"],
|
||||
"option", ["class", "disabled", "label", "selected", "value"],
|
||||
"q", ["class", "cite"],
|
||||
"script", ["src", "type"],
|
||||
"select", ["class", "disabled", "multiple", "name", "size", "tabindex"],
|
||||
"style", ["type"],
|
||||
"table", ["class", "summary"],
|
||||
"th", ["class", "colspan", "rowspan"],
|
||||
"td", ["class", "colspan", "rowspan"],
|
||||
"textarea", ["accesskey", "class", "cols", "disabled", "name", "readonly", "rows", "tabindex"],
|
||||
"param", ["name", "value"],
|
||||
"embed", ["height", "src", "type", "width"]
|
||||
];
|
||||
var tagAttributesRequired = [[], "img", ["alt"]];
|
||||
// white space chars
|
||||
var whitespace = [" ", " ", "\t", "\n", "\r", "\f"];
|
||||
|
||||
})(jQuery);
|
||||
11
js/jquery.ui.touch-punch.min.js
vendored
Normal file
11
js/jquery.ui.touch-punch.min.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* jQuery UI Touch Punch 0.2.2
|
||||
*
|
||||
* Copyright 2011, Dave Furfero
|
||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
*
|
||||
* Depends:
|
||||
* jquery.ui.widget.js
|
||||
* jquery.ui.mouse.js
|
||||
*/
|
||||
(function(b){b.support.touch="ontouchend" in document;if(!b.support.touch){return;}var c=b.ui.mouse.prototype,e=c._mouseInit,a;function d(g,h){if(g.originalEvent.touches.length>1){return;}g.preventDefault();var i=g.originalEvent.changedTouches[0],f=document.createEvent("MouseEvents");f.initMouseEvent(h,true,true,window,1,i.screenX,i.screenY,i.clientX,i.clientY,false,false,false,false,0,null);g.target.dispatchEvent(f);}c._touchStart=function(g){var f=this;if(a||!f._mouseCapture(g.originalEvent.changedTouches[0])){return;}a=true;f._touchMoved=false;d(g,"mouseover");d(g,"mousemove");d(g,"mousedown");};c._touchMove=function(f){if(!a){return;}this._touchMoved=true;d(f,"mousemove");};c._touchEnd=function(f){if(!a){return;}d(f,"mouseup");d(f,"mouseout");if(!this._touchMoved){d(f,"click");}a=false;};c._mouseInit=function(){var f=this;f.element.bind("touchstart",b.proxy(f,"_touchStart")).bind("touchmove",b.proxy(f,"_touchMove")).bind("touchend",b.proxy(f,"_touchEnd"));e.call(f);};})(jQuery);
|
||||
501
js/scripts.js
Normal file
501
js/scripts.js
Normal file
@@ -0,0 +1,501 @@
|
||||
var webpage = "";
|
||||
function supportstorage() {
|
||||
if (typeof window.localStorage=='object')
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
function handleSaveLayout() {
|
||||
var e = $(".demo").html();
|
||||
if (!stopsave && e != window.demoHtml) {
|
||||
stopsave++;
|
||||
window.demoHtml = e;
|
||||
saveLayout();
|
||||
stopsave--;
|
||||
}
|
||||
}
|
||||
|
||||
var layouthistory;
|
||||
function saveLayout(){
|
||||
var data = layouthistory;
|
||||
if (!data) {
|
||||
data={};
|
||||
data.count = 0;
|
||||
data.list = [];
|
||||
}
|
||||
if (data.list.length>data.count) {
|
||||
for (i=data.count;i<data.list.length;i++)
|
||||
data.list[i]=null;
|
||||
}
|
||||
data.list[data.count] = window.demoHtml;
|
||||
data.count++;
|
||||
if (supportstorage()) {
|
||||
localStorage.setItem("layoutdata",JSON.stringify(data));
|
||||
}
|
||||
layouthistory = data;
|
||||
//console.log(data);
|
||||
/*$.ajax({
|
||||
type: "POST",
|
||||
url: "/build/saveLayout",
|
||||
data: { layout: $('.demo').html() },
|
||||
success: function(data) {
|
||||
//updateButtonsVisibility();
|
||||
}
|
||||
});*/
|
||||
}
|
||||
|
||||
function downloadLayout(){
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/build/downloadLayout",
|
||||
data: { layout: $('#download-layout').html() },
|
||||
success: function(data) { window.location.href = '/build/download'; }
|
||||
});
|
||||
}
|
||||
|
||||
function downloadHtmlLayout(){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/build/downloadLayout",
|
||||
data: { layout: $('#download-layout').html() },
|
||||
success: function(data) { window.location.href = '/build/downloadHtml'; }
|
||||
});
|
||||
}
|
||||
|
||||
function undoLayout() {
|
||||
var data = layouthistory;
|
||||
//console.log(data);
|
||||
if (data) {
|
||||
if (data.count<2) return false;
|
||||
window.demoHtml = data.list[data.count-2];
|
||||
data.count--;
|
||||
$('.demo').html(window.demoHtml);
|
||||
if (supportstorage()) {
|
||||
localStorage.setItem("layoutdata",JSON.stringify(data));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
/*$.ajax({
|
||||
type: "POST",
|
||||
url: "/build/getPreviousLayout",
|
||||
data: { },
|
||||
success: function(data) {
|
||||
undoOperation(data);
|
||||
}
|
||||
});*/
|
||||
}
|
||||
|
||||
function redoLayout() {
|
||||
var data = layouthistory;
|
||||
if (data) {
|
||||
if (data.list[data.count]) {
|
||||
window.demoHtml = data.list[data.count];
|
||||
data.count++;
|
||||
$('.demo').html(window.demoHtml);
|
||||
if (supportstorage()) {
|
||||
localStorage.setItem("layoutdata",JSON.stringify(data));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
/*
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/build/getPreviousLayout",
|
||||
data: { },
|
||||
success: function(data) {
|
||||
redoOperation(data);
|
||||
}
|
||||
});*/
|
||||
}
|
||||
|
||||
function handleJsIds() {
|
||||
handleModalIds();
|
||||
handleAccordionIds();
|
||||
handleCarouselIds();
|
||||
handleTabsIds()
|
||||
}
|
||||
function handleAccordionIds() {
|
||||
var e = $(".demo #myAccordion");
|
||||
var t = randomNumber();
|
||||
var n = "accordion-" + t;
|
||||
var r;
|
||||
e.attr("id", n);
|
||||
e.find(".accordion-group").each(function(e, t) {
|
||||
r = "accordion-element-" + randomNumber();
|
||||
$(t).find(".accordion-toggle").each(function(e, t) {
|
||||
$(t).attr("data-parent", "#" + n);
|
||||
$(t).attr("href", "#" + r)
|
||||
});
|
||||
$(t).find(".accordion-body").each(function(e, t) {
|
||||
$(t).attr("id", r)
|
||||
})
|
||||
})
|
||||
}
|
||||
function handleCarouselIds() {
|
||||
var e = $(".demo #myCarousel");
|
||||
var t = randomNumber();
|
||||
var n = "carousel-" + t;
|
||||
e.attr("id", n);
|
||||
e.find(".carousel-indicators li").each(function(e, t) {
|
||||
$(t).attr("data-target", "#" + n)
|
||||
});
|
||||
e.find(".left").attr("href", "#" + n);
|
||||
e.find(".right").attr("href", "#" + n)
|
||||
}
|
||||
function handleModalIds() {
|
||||
var e = $(".demo #myModalLink");
|
||||
var t = randomNumber();
|
||||
var n = "modal-container-" + t;
|
||||
var r = "modal-" + t;
|
||||
e.attr("id", r);
|
||||
e.attr("href", "#" + n);
|
||||
e.next().attr("id", n)
|
||||
}
|
||||
function handleTabsIds() {
|
||||
var e = $(".demo #myTabs");
|
||||
var t = randomNumber();
|
||||
var n = "tabs-" + t;
|
||||
e.attr("id", n);
|
||||
e.find(".tab-pane").each(function(e, t) {
|
||||
var n = $(t).attr("id");
|
||||
var r = "panel-" + randomNumber();
|
||||
$(t).attr("id", r);
|
||||
$(t).parent().parent().find("a[href=#" + n + "]").attr("href", "#" + r)
|
||||
})
|
||||
}
|
||||
function randomNumber() {
|
||||
return randomFromInterval(1, 1e6)
|
||||
}
|
||||
function randomFromInterval(e, t) {
|
||||
return Math.floor(Math.random() * (t - e + 1) + e)
|
||||
}
|
||||
function gridSystemGenerator() {
|
||||
$(".lyrow .preview input").bind("keyup", function() {
|
||||
var e = 0;
|
||||
var t = "";
|
||||
var n = $(this).val().split(" ", 12);
|
||||
$.each(n, function(n, r) {
|
||||
e = e + parseInt(r);
|
||||
t += '<div class="span' + r + ' column"></div>'
|
||||
});
|
||||
if (e == 12) {
|
||||
$(this).parent().next().children().html(t);
|
||||
$(this).parent().prev().show()
|
||||
} else {
|
||||
$(this).parent().prev().hide()
|
||||
}
|
||||
})
|
||||
}
|
||||
function configurationElm(e, t) {
|
||||
$(".demo").delegate(".configuration > a", "click", function(e) {
|
||||
e.preventDefault();
|
||||
var t = $(this).parent().next().next().children();
|
||||
$(this).toggleClass("active");
|
||||
t.toggleClass($(this).attr("rel"))
|
||||
});
|
||||
$(".demo").delegate(".configuration .dropdown-menu a", "click", function(e) {
|
||||
e.preventDefault();
|
||||
var t = $(this).parent().parent();
|
||||
var n = t.parent().parent().next().next().children();
|
||||
t.find("li").removeClass("active");
|
||||
$(this).parent().addClass("active");
|
||||
var r = "";
|
||||
t.find("a").each(function() {
|
||||
r += $(this).attr("rel") + " "
|
||||
});
|
||||
t.parent().removeClass("open");
|
||||
n.removeClass(r);
|
||||
n.addClass($(this).attr("rel"))
|
||||
})
|
||||
}
|
||||
function removeElm() {
|
||||
$(".demo").delegate(".remove", "click", function(e) {
|
||||
e.preventDefault();
|
||||
$(this).parent().remove();
|
||||
if (!$(".demo .lyrow").length > 0) {
|
||||
clearDemo()
|
||||
}
|
||||
})
|
||||
}
|
||||
function clearDemo() {
|
||||
$(".demo").empty();
|
||||
layouthistory = null;
|
||||
if (supportstorage())
|
||||
localStorage.removeItem("layoutdata");
|
||||
}
|
||||
function removeMenuClasses() {
|
||||
$("#menu-layoutit li button").removeClass("active")
|
||||
}
|
||||
function changeStructure(e, t) {
|
||||
$("#download-layout ." + e).removeClass(e).addClass(t)
|
||||
}
|
||||
function cleanHtml(e) {
|
||||
$(e).parent().append($(e).children().html())
|
||||
}
|
||||
function downloadLayoutSrc() {
|
||||
var e = "";
|
||||
$("#download-layout").children().html($(".demo").html());
|
||||
var t = $("#download-layout").children();
|
||||
t.find(".preview, .configuration, .drag, .remove").remove();
|
||||
t.find(".lyrow").addClass("removeClean");
|
||||
t.find(".box-element").addClass("removeClean");
|
||||
t.find(".lyrow .lyrow .lyrow .lyrow .lyrow .removeClean").each(function() {
|
||||
cleanHtml(this)
|
||||
});
|
||||
t.find(".lyrow .lyrow .lyrow .lyrow .removeClean").each(function() {
|
||||
cleanHtml(this)
|
||||
});
|
||||
t.find(".lyrow .lyrow .lyrow .removeClean").each(function() {
|
||||
cleanHtml(this)
|
||||
});
|
||||
t.find(".lyrow .lyrow .removeClean").each(function() {
|
||||
cleanHtml(this)
|
||||
});
|
||||
t.find(".lyrow .removeClean").each(function() {
|
||||
cleanHtml(this)
|
||||
});
|
||||
t.find(".removeClean").each(function() {
|
||||
cleanHtml(this)
|
||||
});
|
||||
t.find(".removeClean").remove();
|
||||
$("#download-layout .column").removeClass("ui-sortable");
|
||||
$("#download-layout .row-fluid").removeClass("clearfix").children().removeClass("column");
|
||||
if ($("#download-layout .container").length > 0) {
|
||||
changeStructure("row-fluid", "row")
|
||||
}
|
||||
formatSrc = $.htmlClean($("#download-layout").html(), {
|
||||
format: true,
|
||||
allowedAttributes: [
|
||||
["id"],
|
||||
["class"],
|
||||
["data-toggle"],
|
||||
["data-target"],
|
||||
["data-parent"],
|
||||
["role"],
|
||||
["data-dismiss"],
|
||||
["aria-labelledby"],
|
||||
["aria-hidden"],
|
||||
["data-slide-to"],
|
||||
["data-slide"]
|
||||
]
|
||||
});
|
||||
$("#download-layout").html(formatSrc);
|
||||
$("#downloadModal textarea").empty();
|
||||
$("#downloadModal textarea").val(formatSrc)
|
||||
webpage = formatSrc;
|
||||
}
|
||||
|
||||
var currentDocument = null;
|
||||
var timerSave = 1000;
|
||||
var stopsave = 0;
|
||||
var startdrag = 0;
|
||||
var demoHtml = $(".demo").html();
|
||||
var currenteditor = null;
|
||||
$(window).resize(function() {
|
||||
$("body").css("min-height", $(window).height() - 90);
|
||||
$(".demo").css("min-height", $(window).height() - 160)
|
||||
});
|
||||
|
||||
function restoreData(){
|
||||
if (supportstorage()) {
|
||||
layouthistory = JSON.parse(localStorage.getItem("layoutdata"));
|
||||
if (!layouthistory) return false;
|
||||
window.demoHtml = layouthistory.list[layouthistory.count-1];
|
||||
if (window.demoHtml) $(".demo").html(window.demoHtml);
|
||||
}
|
||||
}
|
||||
|
||||
function initContainer(){
|
||||
$(".demo, .demo .column").sortable({
|
||||
connectWith: ".column",
|
||||
opacity: .35,
|
||||
handle: ".drag",
|
||||
start: function(e,t) {
|
||||
if (!startdrag) stopsave++;
|
||||
startdrag = 1;
|
||||
},
|
||||
stop: function(e,t) {
|
||||
if(stopsave>0) stopsave--;
|
||||
startdrag = 0;
|
||||
}
|
||||
});
|
||||
configurationElm();
|
||||
}
|
||||
$(document).ready(function() {
|
||||
CKEDITOR.disableAutoInline = true;
|
||||
restoreData();
|
||||
var contenthandle = CKEDITOR.replace( 'contenteditor' ,{
|
||||
language: 'en',
|
||||
contentsCss: ['css/bootstrap-combined.min.css'],
|
||||
allowedContent: true
|
||||
});
|
||||
$("body").css("min-height", $(window).height() - 50);
|
||||
$(".demo").css("min-height", $(window).height() - 130);
|
||||
$(".sidebar-nav .lyrow").draggable({
|
||||
connectToSortable: ".demo",
|
||||
helper: "clone",
|
||||
handle: ".drag",
|
||||
start: function(e,t) {
|
||||
if (!startdrag) stopsave++;
|
||||
startdrag = 1;
|
||||
},
|
||||
drag: function(e, t) {
|
||||
t.helper.width(400)
|
||||
},
|
||||
stop: function(e, t) {
|
||||
$(".demo .column").sortable({
|
||||
opacity: .35,
|
||||
connectWith: ".column",
|
||||
start: function(e,t) {
|
||||
if (!startdrag) stopsave++;
|
||||
startdrag = 1;
|
||||
},
|
||||
stop: function(e,t) {
|
||||
if(stopsave>0) stopsave--;
|
||||
startdrag = 0;
|
||||
}
|
||||
});
|
||||
if(stopsave>0) stopsave--;
|
||||
startdrag = 0;
|
||||
}
|
||||
});
|
||||
$(".sidebar-nav .box").draggable({
|
||||
connectToSortable: ".column",
|
||||
helper: "clone",
|
||||
handle: ".drag",
|
||||
start: function(e,t) {
|
||||
if (!startdrag) stopsave++;
|
||||
startdrag = 1;
|
||||
},
|
||||
drag: function(e, t) {
|
||||
t.helper.width(400)
|
||||
},
|
||||
stop: function() {
|
||||
handleJsIds();
|
||||
if(stopsave>0) stopsave--;
|
||||
startdrag = 0;
|
||||
}
|
||||
});
|
||||
initContainer();
|
||||
$('body.edit .demo').on("click","[data-target=#editorModal]",function(e) {
|
||||
e.preventDefault();
|
||||
currenteditor = $(this).parent().parent().find('.view');
|
||||
var eText = currenteditor.html();
|
||||
contenthandle.setData(eText);
|
||||
});
|
||||
$("#savecontent").click(function(e) {
|
||||
e.preventDefault();
|
||||
currenteditor.html(contenthandle.getData());
|
||||
});
|
||||
$("[data-target=#downloadModal]").click(function(e) {
|
||||
e.preventDefault();
|
||||
downloadLayoutSrc();
|
||||
});
|
||||
$("[data-target=#shareModal]").click(function(e) {
|
||||
e.preventDefault();
|
||||
handleSaveLayout();
|
||||
});
|
||||
$("#download").click(function() {
|
||||
downloadLayout();
|
||||
return false
|
||||
});
|
||||
$("#downloadhtml").click(function() {
|
||||
downloadHtmlLayout();
|
||||
return false
|
||||
});
|
||||
$("#edit").click(function() {
|
||||
$("body").removeClass("devpreview sourcepreview");
|
||||
$("body").addClass("edit");
|
||||
removeMenuClasses();
|
||||
$(this).addClass("active");
|
||||
return false
|
||||
});
|
||||
$("#clear").click(function(e) {
|
||||
e.preventDefault();
|
||||
clearDemo()
|
||||
});
|
||||
$("#devpreview").click(function() {
|
||||
$("body").removeClass("edit sourcepreview");
|
||||
$("body").addClass("devpreview");
|
||||
removeMenuClasses();
|
||||
$(this).addClass("active");
|
||||
return false
|
||||
});
|
||||
$("#sourcepreview").click(function() {
|
||||
$("body").removeClass("edit");
|
||||
$("body").addClass("devpreview sourcepreview");
|
||||
removeMenuClasses();
|
||||
$(this).addClass("active");
|
||||
return false
|
||||
});
|
||||
$("#fluidPage").click(function(e) {
|
||||
e.preventDefault();
|
||||
changeStructure("container", "container-fluid");
|
||||
$("#fixedPage").removeClass("active");
|
||||
$(this).addClass("active");
|
||||
downloadLayoutSrc()
|
||||
});
|
||||
$("#fixedPage").click(function(e) {
|
||||
e.preventDefault();
|
||||
changeStructure("container-fluid", "container");
|
||||
$("#fluidPage").removeClass("active");
|
||||
$(this).addClass("active");
|
||||
downloadLayoutSrc()
|
||||
});
|
||||
$(".nav-header").click(function() {
|
||||
$(".sidebar-nav .boxes, .sidebar-nav .rows").hide();
|
||||
$(this).next().slideDown()
|
||||
});
|
||||
$('#undo').click(function(){
|
||||
stopsave++;
|
||||
if (undoLayout()) initContainer();
|
||||
stopsave--;
|
||||
});
|
||||
$('#redo').click(function(){
|
||||
stopsave++;
|
||||
if (redoLayout()) initContainer();
|
||||
stopsave--;
|
||||
});
|
||||
removeElm();
|
||||
gridSystemGenerator();
|
||||
setInterval(function() {
|
||||
handleSaveLayout()
|
||||
}, timerSave)
|
||||
})
|
||||
|
||||
function saveHtml()
|
||||
{
|
||||
/* FM aka Vegetam Added the function that save the file in the directory Downloads. Work only to Chrome Firefox And IE*/
|
||||
if (navigator.appName =="Microsoft Internet Explorer" && window.ActiveXObject)
|
||||
{
|
||||
var locationFile = location.href.toString();
|
||||
var dlg = false;
|
||||
with(document){
|
||||
ir=createElement('iframe');
|
||||
ir.id='ifr';
|
||||
ir.location='about.blank';
|
||||
ir.style.display='none';
|
||||
body.appendChild(ir);
|
||||
with(getElementById('ifr').contentWindow.document){
|
||||
open("text/html", "replace");
|
||||
charset = "utf-8";
|
||||
write(webpage);
|
||||
close();
|
||||
document.charset = "utf-8";
|
||||
dlg = execCommand('SaveAs', false, locationFile);
|
||||
body.removeChild(ir);
|
||||
}
|
||||
return dlg;
|
||||
}
|
||||
}
|
||||
else{
|
||||
var blob = new Blob([webpage], {type: "text/html;charset=utf-8"});
|
||||
saveAs(blob, "webpage.html");
|
||||
}
|
||||
}
|
||||
|
||||
318
js/scripts_new.js
Normal file
318
js/scripts_new.js
Normal file
@@ -0,0 +1,318 @@
|
||||
function handleSaveLayout()
|
||||
{
|
||||
var e = $(".demo").html();
|
||||
if (e != window.demoHtml)
|
||||
{
|
||||
saveLayout();
|
||||
window.demoHtml = e
|
||||
}
|
||||
}
|
||||
function handleJsIds()
|
||||
{
|
||||
handleModalIds();
|
||||
handleAccordionIds();
|
||||
handleCarouselIds();
|
||||
handleTabsIds()
|
||||
}
|
||||
function handleAccordionIds()
|
||||
{
|
||||
var e = $(".demo #myAccordion");
|
||||
var t = randomNumber();
|
||||
var n = "panel-" + t;
|
||||
var r;
|
||||
e.attr("id", n);
|
||||
e.find(".panel").each(function (e, t)
|
||||
{
|
||||
r = "panel-element-" + randomNumber();
|
||||
$(t).find(".panel-title").each(function (e, t)
|
||||
{
|
||||
$(t).attr("data-parent", "#" + n);
|
||||
$(t).attr("href", "#" + r)
|
||||
});
|
||||
$(t).find(".panel-collapse").each(function (e, t)
|
||||
{
|
||||
$(t).attr("id", r)
|
||||
})
|
||||
})
|
||||
}
|
||||
function handleCarouselIds()
|
||||
{
|
||||
var e = $(".demo #myCarousel");
|
||||
var t = randomNumber();
|
||||
var n = "carousel-" + t;
|
||||
e.attr("id", n);
|
||||
e.find(".carousel-indicators li").each(function (e, t)
|
||||
{
|
||||
$(t).attr("data-target", "#" + n)
|
||||
});
|
||||
e.find(".left").attr("href", "#" + n);
|
||||
e.find(".right").attr("href", "#" + n)
|
||||
}
|
||||
function handleModalIds()
|
||||
{
|
||||
var e = $(".demo #myModalLink");
|
||||
var t = randomNumber();
|
||||
var n = "modal-container-" + t;
|
||||
var r = "modal-" + t;
|
||||
e.attr("id", r);
|
||||
e.attr("href", "#" + n);
|
||||
e.next().attr("id", n)
|
||||
}
|
||||
function handleTabsIds()
|
||||
{
|
||||
var e = $(".demo #myTabs");
|
||||
var t = randomNumber();
|
||||
var n = "tabs-" + t;
|
||||
e.attr("id", n);
|
||||
e.find(".tab-pane").each(function (e, t)
|
||||
{
|
||||
var n = $(t).attr("id");
|
||||
var r = "panel-" + randomNumber();
|
||||
$(t).attr("id", r);
|
||||
$(t).parent().parent().find("a[href=#" + n + "]").attr("href", "#" + r)
|
||||
})
|
||||
}
|
||||
function randomNumber()
|
||||
{
|
||||
return randomFromInterval(1, 1e6)
|
||||
}
|
||||
function randomFromInterval(e, t)
|
||||
{
|
||||
return Math.floor(Math.random() * (t - e + 1) + e)
|
||||
}
|
||||
function gridSystemGenerator()
|
||||
{
|
||||
$(".lyrow .preview input").bind("keyup", function ()
|
||||
{
|
||||
var e = 0;
|
||||
var t = "";
|
||||
var n = false;
|
||||
var r = $(this).val().split(" ", 12);
|
||||
$.each(r, function (r, i)
|
||||
{
|
||||
if (!n)
|
||||
{
|
||||
if (parseInt(i) <= 0) n = true;
|
||||
e = e + parseInt(i);
|
||||
t += '<div class="col-md-' + i + ' column"></div>'
|
||||
}
|
||||
});
|
||||
if (e == 12 && !n)
|
||||
{
|
||||
$(this).parent().next().children().html(t);
|
||||
$(this).parent().prev().show()
|
||||
}
|
||||
else
|
||||
{
|
||||
$(this).parent().prev().hide()
|
||||
}
|
||||
})
|
||||
}
|
||||
function configurationElm(e, t)
|
||||
{
|
||||
$(".demo").delegate(".configuration > a", "click", function (e)
|
||||
{
|
||||
e.preventDefault();
|
||||
var t = $(this).parent().next().next().children();
|
||||
$(this).toggleClass("active");
|
||||
t.toggleClass($(this).attr("rel"))
|
||||
});
|
||||
$(".demo").delegate(".configuration .dropdown-menu a", "click", function (e)
|
||||
{
|
||||
e.preventDefault();
|
||||
var t = $(this).parent().parent();
|
||||
var n = t.parent().parent().next().next().children();
|
||||
t.find("li").removeClass("active");
|
||||
$(this).parent().addClass("active");
|
||||
var r = "";
|
||||
t.find("a").each(function ()
|
||||
{
|
||||
r += $(this).attr("rel") + " "
|
||||
});
|
||||
t.parent().removeClass("open");
|
||||
n.removeClass(r);
|
||||
n.addClass($(this).attr("rel"))
|
||||
})
|
||||
}
|
||||
function removeElm()
|
||||
{
|
||||
$(".demo").delegate(".remove", "click", function (e)
|
||||
{
|
||||
e.preventDefault();
|
||||
$(this).parent().remove();
|
||||
if (!$(".demo .lyrow").length > 0)
|
||||
{
|
||||
clearDemo()
|
||||
}
|
||||
})
|
||||
}
|
||||
function clearDemo()
|
||||
{
|
||||
$(".demo").empty()
|
||||
}
|
||||
function removeMenuClasses()
|
||||
{
|
||||
$("#menu-layoutit li button").removeClass("active")
|
||||
}
|
||||
function changeStructure(e, t)
|
||||
{
|
||||
$("#download-layout ." + e).removeClass(e).addClass(t)
|
||||
}
|
||||
function cleanHtml(e)
|
||||
{
|
||||
$(e).parent().append($(e).children().html())
|
||||
}
|
||||
function downloadLayoutSrc()
|
||||
{
|
||||
var e = "";
|
||||
$("#download-layout").children().html($(".demo").html());
|
||||
var t = $("#download-layout").children();
|
||||
t.find(".preview, .configuration, .drag, .remove").remove();
|
||||
t.find(".lyrow").addClass("removeClean");
|
||||
t.find(".box-element").addClass("removeClean");
|
||||
t.find(".lyrow .lyrow .lyrow .lyrow .lyrow .removeClean").each(function ()
|
||||
{
|
||||
cleanHtml(this)
|
||||
});
|
||||
t.find(".lyrow .lyrow .lyrow .lyrow .removeClean").each(function ()
|
||||
{
|
||||
cleanHtml(this)
|
||||
});
|
||||
t.find(".lyrow .lyrow .lyrow .removeClean").each(function ()
|
||||
{
|
||||
cleanHtml(this)
|
||||
});
|
||||
t.find(".lyrow .lyrow .removeClean").each(function ()
|
||||
{
|
||||
cleanHtml(this)
|
||||
});
|
||||
t.find(".lyrow .removeClean").each(function ()
|
||||
{
|
||||
cleanHtml(this)
|
||||
});
|
||||
t.find(".removeClean").each(function ()
|
||||
{
|
||||
cleanHtml(this)
|
||||
});
|
||||
t.find(".removeClean").remove();
|
||||
$("#download-layout .column").removeClass("ui-sortable");
|
||||
$("#download-layout .row-fluid").removeClass("clearfix").children().removeClass("column");
|
||||
if ($("#download-layout .container").length > 0)
|
||||
{
|
||||
changeStructure("row-fluid", "row")
|
||||
}
|
||||
formatSrc = $.htmlClean($("#download-layout").html(), {
|
||||
format: true,
|
||||
allowedAttributes: [["id"], ["class"], ["data-toggle"], ["data-target"], ["data-parent"], ["role"], ["data-dismiss"], ["aria-labelledby"], ["aria-hidden"], ["data-slide-to"], ["data-slide"]]
|
||||
});
|
||||
$("#download-layout").html(formatSrc);
|
||||
$("#downloadModal textarea").empty();
|
||||
$("#downloadModal textarea").val(formatSrc)
|
||||
}
|
||||
var currentDocument = null;
|
||||
var timerSave = 2e3;
|
||||
var demoHtml = $(".demo").html();
|
||||
$(window).resize(function ()
|
||||
{
|
||||
$("body").css("min-height", $(window).height() - 90);
|
||||
$(".demo").css("min-height", $(window).height() - 160)
|
||||
});
|
||||
$(document).ready(function ()
|
||||
{
|
||||
$("body").css("min-height", $(window).height() - 90);
|
||||
$(".demo").css("min-height", $(window).height() - 160);
|
||||
$(".demo, .demo .column").sortable(
|
||||
{
|
||||
connectWith: ".column",
|
||||
opacity: .35,
|
||||
handle: ".drag"
|
||||
});
|
||||
$(".sidebar-nav .lyrow").draggable(
|
||||
{
|
||||
connectToSortable: ".demo",
|
||||
helper: "clone",
|
||||
handle: ".drag",
|
||||
drag: function (e, t)
|
||||
{
|
||||
t.helper.width(400)
|
||||
},
|
||||
stop: function (e, t)
|
||||
{
|
||||
$(".demo .column").sortable(
|
||||
{
|
||||
opacity: .35,
|
||||
connectWith: ".column"
|
||||
})
|
||||
}
|
||||
});
|
||||
$(".sidebar-nav .box").draggable(
|
||||
{
|
||||
connectToSortable: ".column",
|
||||
helper: "clone",
|
||||
handle: ".drag",
|
||||
drag: function (e, t)
|
||||
{
|
||||
t.helper.width(400)
|
||||
},
|
||||
stop: function ()
|
||||
{
|
||||
handleJsIds()
|
||||
}
|
||||
});
|
||||
$("[data-target=#downloadModal]").click(function (e)
|
||||
{
|
||||
e.preventDefault();
|
||||
downloadLayoutSrc()
|
||||
});
|
||||
$("#download").click(function ()
|
||||
{
|
||||
downloadLayout();
|
||||
return false
|
||||
});
|
||||
$("#downloadhtml").click(function ()
|
||||
{
|
||||
downloadHtmlLayout();
|
||||
return false
|
||||
});
|
||||
$("#edit").click(function ()
|
||||
{
|
||||
$("body").removeClass("devpreview sourcepreview");
|
||||
$("body").addClass("edit");
|
||||
removeMenuClasses();
|
||||
$(this).addClass("active");
|
||||
return false
|
||||
});
|
||||
$("#clear").click(function (e)
|
||||
{
|
||||
e.preventDefault();
|
||||
clearDemo()
|
||||
});
|
||||
$("#devpreview").click(function ()
|
||||
{
|
||||
$("body").removeClass("edit sourcepreview");
|
||||
$("body").addClass("devpreview");
|
||||
removeMenuClasses();
|
||||
$(this).addClass("active");
|
||||
return false
|
||||
});
|
||||
$("#sourcepreview").click(function ()
|
||||
{
|
||||
$("body").removeClass("edit");
|
||||
$("body").addClass("devpreview sourcepreview");
|
||||
removeMenuClasses();
|
||||
$(this).addClass("active");
|
||||
return false
|
||||
});
|
||||
$(".nav-header").click(function ()
|
||||
{
|
||||
$(".sidebar-nav .boxes, .sidebar-nav .rows").hide();
|
||||
$(this).next().slideDown()
|
||||
});
|
||||
removeElm();
|
||||
configurationElm();
|
||||
gridSystemGenerator();
|
||||
setInterval(function ()
|
||||
{
|
||||
handleSaveLayout()
|
||||
}, timerSave)
|
||||
})
|
||||
Reference in New Issue
Block a user