Permalink
Browse files

merge ui with main? i don't understand how the project is currently l…

…aid out.
  • Loading branch information...
1 parent 6c59d93 commit 2d550a99265f8600a331ee2a89d2fecc92ef2b4d @alecgorge alecgorge committed May 12, 2011
Showing with 172 additions and 20 deletions.
  1. +17 −15 controls/wysiwyg.image.js
  2. +107 −1 jquery.wysiwyg.js
  3. +46 −1 src/dialogs/default.css
  4. +1 −1 src/jquery.wysiwyg.js
  5. +1 −2 test/unified_dialog_ui.html
View
@@ -68,20 +68,20 @@
formTextReset = $.wysiwyg.i18n.t(formTextReset, "dialogs");
}
- formImageHtml = '<form class="wysiwyg"><fieldset>' +
- '<label>' + formTextPreview + ': <img src="" alt="' + formTextPreview + '" style="float: right; margin: 5px; width: 80px; height: 60px; border: 1px solid rgb(192, 192, 192);"/></label>' +
- '<label>' + formTextUrl + ': <input type="text" name="src" value=""/></label>' +
- '<label>' + formTextTitle + ': <input type="text" name="imgtitle" value=""/></label>' +
- '<label>' + formTextDescription + ': <input type="text" name="description" value=""/></label>' +
- '<label>' + formTextWidth + ' x ' + formTextHeight + ': <input type="text" name="width" value="" class="width"/> x <input type="text" name="height" value="" class="height"/></label>' +
- '<label>' + formTextOriginal + ': <input type="text" name="naturalWidth" value="" class="width" disabled="disabled"/> x ' +
- '<input type="text" name="naturalHeight" value="" class="height" disabled="disabled"/></label>' +
- '<label>' + formTextFloat + ': <select name="float">' +
+ formImageHtml = '<form class="wysiwyg" id="wysiwyg-addImage"><fieldset>' +
+ '<div class="form-row"><span class="form-row-key">' + formTextPreview + ':</span><div class="form-row-value"><img src="" alt="' + formTextPreview + '" style="margin: 2px; width: 80px; height: 60px; border: 1px solid rgb(192, 192, 192);"/></div></div>'+
+ '<div class="form-row"><label for="name">' + formTextUrl + ':</label><div class="form-row-value"><input type="text" name="src" value=""/></div></div>' +
+ '<div class="form-row"><label for="name">' + formTextTitle + ':</label><div class="form-row-value"><input type="text" name="imgtitle" value=""/></div></div>' +
+ '<div class="form-row"><label for="name">' + formTextDescription + ':</label><div class="form-row-value"><input type="text" name="description" value=""/></div></div>' +
+ '<div class="form-row"><label for="name">' + formTextWidth + ' x ' + formTextHeight + ':</label><div class="form-row-value"><input type="text" name="width" value="" class="width-small"/> x <input type="text" name="height" value="" class="width-small"/></div></div>' +
+ '<div class="form-row"><label for="name">' + formTextOriginal + ':</label><div class="form-row-value"><input type="text" name="naturalWidth" value="" class="width-small" disabled="disabled"/> x ' +
+ '<input type="text" name="naturalHeight" value="" class="width-small" disabled="disabled"/></div></div>' +
+ '<div class="form-row"><label for="name">' + formTextFloat + ':</label><div class="form-row-value"><select name="float">' +
'<option value="">' + formTextFloatNone + '</option>' +
'<option value="left">' + formTextFloatLeft + '</option>' +
- '<option value="right">' + formTextFloatRight + '</option></select></label>' +
- '<input type="submit" class="button" value="' + formTextSubmit + '"/> ' +
- '<input type="reset" value="' + formTextReset + '"/></fieldset></form>';
+ '<option value="right">' + formTextFloatRight + '</option></select></div></div>' +
+ '<div class="form-row form-row-last"><label for="name"></label><div class="form-row-value"><input type="submit" class="button" value="' + formTextSubmit + '"/> ' +
+ '<input type="reset" value="' + formTextReset + '"/></div></div></fieldset></form>';
if (img.self) {
img.src = img.self.src ? img.self.src : "";
@@ -97,7 +97,8 @@
});
$(adialog).bind("afterOpen", function (e, dialog) {
- $("input:submit", dialog).click(function (e) {
+ $("form#wysiwyg-addImage", dialog).submit(function (e) {
+ e.preventDefault();
self.processInsert(dialog.container, Wysiwyg, img);
adialog.close();
@@ -112,7 +113,7 @@
e.stopPropagation();
});
- self.makeForm($(formImageHtml), img);
+ self.makeForm(dialog, img);
});
adialog.open();
@@ -132,7 +133,7 @@
found,
baseUrl;
- if (Wysiwyg.options.controlImage.forceRelativeUrls) {
+ if (Wysiwyg.options.controlImage && Wysiwyg.options.controlImage.forceRelativeUrls) {
baseUrl = window.location.protocol + "//" + window.location.hostname;
if (0 === url.indexOf(baseUrl)) {
url = url.substr(baseUrl.length);
@@ -190,6 +191,7 @@
},
makeForm: function (form, img) {
+ console.log(form.find("input[name=src]"));
form.find("input[name=src]").val(img.src);
form.find("input[name=imgtitle]").val(img.title);
form.find("input[name=description]").val(img.alt);
View
@@ -498,7 +498,9 @@
rmFormat: {
rmMsWordMarkup: false
}
- }
+ },
+
+ dialog : "default"
};
this.availableControlProperties = [
@@ -1868,6 +1870,110 @@
}
}
};
+
+
+ /**
+ * Unifies dialog methods to allow custom implementations
+ *
+ * Events:
+ * * afterOpen
+ * * beforeShow
+ * * afterShow
+ * * beforeHide
+ * * afterHide
+ * * beforeClose
+ * * afterClose
+ *
+ * Example:
+ * var dialog = new ($.wysiwyg.dialog)($('#idToTextArea').data('wysiwyg'), {"title": "Test", "content": "form data, etc."});
+ *
+ * dialog.bind("afterOpen", function () { alert('you should see a dialog behind this one!'); });
+ *
+ * dialog.open();
+ *
+ *
+ */
+ $.wysiwyg.dialog = function (jWysiwyg, opts) {
+ var theme = jWysiwyg.options.dialog,
+ obj = $.wysiwyg.dialog.createDialog(jWysiwyg.options.dialog),
+ that = this,
+ $that = $(that);
+
+ this.options = {
+ "title": "Title",
+ "content": "Content"
+ }
+
+ this.isOpen = false;
+
+ $.extend(this.options, opts);
+
+ // Opens a dialog with the specified content
+ this.open = function () {
+ this.isOpen = true;
+
+ obj.init.apply(that, []);
+ var $dialog = obj.show.apply(that, []);
+
+ $that.trigger("afterOpen", [$dialog]);
+ };
+
+ this.show = function () {
+ this.isOpen = true;
+
+ $that.trigger("beforeShow");
+
+ var $dialog = obj.show.apply(that, []);
+
+ $that.trigger("afterShow");
+ };
+
+ this.hide = function () {
+ this.isOpen = false;
+
+ $that.trigger("beforeHide");
+
+ var $dialog = obj.hide.apply(that, []);
+
+ $that.trigger("afterHide", [$dialog]);
+ }
+
+ // Closes the dialog window
+ this.close = function () {
+ this.isOpen = false;
+
+ var $dialog = obj.hide.apply(that, []);
+
+ $that.trigger("beforeClose", [$dialog]);
+
+ obj.destroy.apply(that, []);
+
+ $that.trigger("afterClose", [$dialog]);
+ };
+
+ return this;
+ };
+
+ // "Static" Dialog methods
+ $.extend(true, $.wysiwyg.dialog, {
+ _themes : {}, // sample {"Theme Name": object}
+ _theme : "", // the current theme
+
+ register : function(name, obj) {
+ $.wysiwyg.dialog._themes[name] = obj;
+ },
+
+ deregister : function (name) {
+ delete $.wysiwyg.dialog._themes[name];
+ },
+
+ createDialog : function (name) {
+ console.log($.wysiwyg.dialog._themes, name);
+ return new ($.wysiwyg.dialog._themes[name]);
+ }
+ });
+
+ // end Dialog
$.fn.wysiwyg = function (method) {
var args = arguments, plugin;
View
@@ -47,6 +47,51 @@
.wysiwyg-dialog form.wysiwyg fieldset {
border:1px #ccc solid;
}
+
.wysiwyg-dialog form.wysiwyg legend {
padding:7px;
-}
+}
+
+.wysiwyg-dialog form.wysiwyg .form-row {
+ clear:both;
+ padding:4px 0;
+}
+
+.wysiwyg-dialog form.wysiwyg .form-row label, .wysiwyg-dialog form.wysiwyg .form-row .form-row-key {
+ display:block;
+ float:left;
+ width:35%;
+ text-align:right;
+ padding:4px 5px;
+}
+
+.wysiwyg-dialog form.wysiwyg .form-row .form-row-value {
+ display:block;
+ float:left;
+ width:55%;
+}
+
+.wysiwyg-dialog form.wysiwyg .form-row input.width-auto {
+ width:auto;
+}
+
+.wysiwyg-dialog form.wysiwyg input.width-small {
+ width:50px;
+ min-width:50px;
+ max-width:50px;
+}
+
+.wysiwyg-dialog form.wysiwyg input, .wysiwyg-dialog form.wysiwyg select {
+ padding:2px;
+ width:100%;
+ margin:2px;
+}
+
+.wysiwyg-dialog form.wysiwyg input[type=submit], .wysiwyg-dialog form.wysiwyg input[type=reset] {
+ padding:2px 7px;
+ width:auto;
+}
+
+
+
+
View
@@ -232,7 +232,7 @@
}
});
-
+ // end Dialog
// Wysiwyg
@@ -10,8 +10,7 @@
<!--[if IE 8]>
<![endif]-->
<script src="../lib/jquery1.5.js" type="text/javascript" charset="utf-8"></script>
- <script src="../src/jquery.wysiwyg.js" type="text/javascript" charset="utf-8"></script>
- <script src="../src/controls/default.js" type="text/javascript" charset="utf-8"></script>
+ <script src="../jquery.wysiwyg.js" type="text/javascript" charset="utf-8"></script>
<script src="../src/dialogs/default.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="../controls/wysiwyg.image.js"></script>
<script type="text/javascript" charset="utf-8">

0 comments on commit 2d550a9

Please sign in to comment.